<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app"></div>
  <script>
    const obj={name:'杨老师'}
    function effect() {
      document.querySelector('#app').innerHTML=obj.name
    }
    effect()
    // proxy就是obj的代理对象,读取 赋值
    const proxy=new Proxy(obj,{
      get(target,key){
        return target[key]
      },
      set(target,key,value){
        target[key]=value
        effect()
        return true
      }
    });
  </script>
</body>
</html>